home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / utils / fmgr / assoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  2.8 KB  |  86 lines

  1. /* ----------------------------------------------------------------
  2.  *    assoc.h
  3.  *
  4.  *    $Header: /private/postgres/src/utils/fmgr/RCS/assoc.h,v 1.4 1991/11/09 01:53:55 mer Exp $
  5.  * ----------------------------------------------------------------
  6.  */
  7.  
  8. #ifndef ASSOC_DEFD
  9. #define ASSOC_DEFD
  10.  
  11. #include "assoc_int.h"
  12.  
  13.  
  14. /***********************************************************************
  15. **
  16. **  See documentation in "assoc.c"
  17. **
  18. ***********************************************************************/
  19.  
  20. /*****/
  21. /* A handle on an associative memory */
  22. #define assoc_mem assoc_memory
  23.  
  24. /*****/
  25. /* Raw memory pointers from an associative memory. Do not use free() on
  26. ** them.  See assoc_free(). */
  27. #define mem_cell H_memory_cell
  28.  
  29. /*****/
  30. /***** Get unique stored string associated with a memory cell which
  31.        was returned by assoc(), assoc_lookup() or assoc_seq(). */
  32. #define string_from_cell(cell,table)  str_from_cell(cell,table)
  33.  
  34.  
  35. /*****/
  36. /***** Get memory cell associated with a string which was returned by
  37. **     string_from_cell  */
  38. #define cell_from_string(string,table) cell_from_str(string,table)
  39.  
  40. /*****/
  41. /***** returns number of entries currently in table */
  42. #define assoc_num_entries(table) (table->entries)
  43.  
  44. #endif ASSOC_DEFD
  45.  
  46. /*
  47.  * assoc.c  -- Function prototypes
  48.  */
  49. assoc_mem new_assoc_mem ARGS((int value_size ));
  50.  
  51. /***** Associates a new cell with a given string. */
  52. mem_cell assoc ARGS((char *string , assoc_mem table ));
  53.  
  54. /* Is like assoc, except uses counted string, rather that null-terminated */
  55. mem_cell assocn ARGS((char *string , int length , assoc_mem table ));
  56. mem_cell assocnf ARGS((char *string , int length , assoc_mem table ));
  57.  
  58. /***** Looks for a cell previously associated with a given string */
  59. mem_cell assoc_lookup ARGS((char *string , assoc_mem table ));
  60.  
  61. /* Like assoc_lookup, except uses counted string, rather than null-
  62. ** terminated string
  63. */
  64. mem_cell assocn_lookup ARGS((char *string , int length , assoc_mem table ));
  65. mem_cell assocnf_lookup ARGS((char *string , int length , assoc_mem table ));
  66.  
  67. /* Sequences through a table, returning the cells found there in a
  68. ** non-deterministic order.  If you put cells into the table as you
  69. ** are sequencing through, the sequencer may find the added value or
  70. ** it may not, so you probably do not want to do that.  Set the variable
  71. ** "seq" to zero before the firished when it returns NULL;
  72. */
  73. mem_cell assoc_seq ARGS((assoc_mem table , int *num ));
  74.  
  75. /***** Removes a memory cell from a table */
  76. int assoc_free ARGS((mem_cell cell , assoc_mem table ));
  77.  
  78. /* Deallocates the memory associated with an assoc_mem table and returns zero,
  79. ** if the table was empty.  Otherwize it just returns the number of entries
  80. ** remaining in the table.
  81. */
  82. int assoc_mem_free ARGS((assoc_mem table ));
  83.  
  84. /***** Empties a table, then removes it. */
  85. int assoc_mem_remove ARGS((assoc_mem table ));
  86.